import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MenuVO, MenuForm, MenuQuery } from '@/api/shopping/titlemenu/types';

/**
 * 查询小程序首页菜单入口列表
 * @param query
 * @returns {*}
 */

export const listMenu = (query?: MenuQuery): AxiosPromise<MenuVO[]> => {
  return request({
    url: '/shopping/menu/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询小程序首页菜单入口详细
 * @param id
 */
export const getMenu = (id: string | number): AxiosPromise<MenuVO> => {
  return request({
    url: '/shopping/menu/' + id,
    method: 'get'
  });
};

/**
 * 新增小程序首页菜单入口
 * @param data
 */
export const addMenu = (data: MenuForm) => {
  return request({
    url: '/shopping/menu',
    method: 'post',
    data: data
  });
};

/**
 * 修改小程序首页菜单入口
 * @param data
 */
export const updateMenu = (data: MenuForm) => {
  return request({
    url: '/shopping/menu',
    method: 'put',
    data: data
  });
};

/**
 * 删除小程序首页菜单入口
 * @param id
 */
export const delMenu = (id: string | number | Array<string | number>) => {
  return request({
    url: '/shopping/menu/' + id,
    method: 'delete'
  });
};
